const Topic = require("../schema/topic");
// 获取话题列表
const getlist = (keywords, size, page) => {
    return Topic.find({ name: { $regex: keywords } })
        .limit(size)
        .skip(page * size);
};

// 获取话题详情
const detail = (id, selects = "") => {
    return Topic.findById(id).select(selects);
};

// 创建话题
const create = (topic) => {
    return Topic.create(topic);
};

// 更新话题
const update = (id, topic) => {
    return Topic.findByIdAndUpdate(id, topic);
};

module.exports = {
    getlist,
    detail,
    create,
    update,
};
